#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

void vectorPrint(int v) {
    cout << v << " ";
}

void test01() {
    vector<int> v1;
    vector<int> v2;

    for (int i = 0; i < 10; ++i) {
        v1.push_back(i);
        v2.push_back(i + 5);
    }

    cout << "容器 v1" << endl;
    for_each(v1.begin(), v1.end(), vectorPrint);
    cout << endl;

    cout << "容器 v2" << endl;
    for_each(v2.begin(), v2.end(), vectorPrint);
    cout << endl;

    vector<int> vDest;
    vDest.resize(max(v1.size(), v2.size()));
    vector<int>::iterator itEnd = set_difference(v1.begin(), v1.end(), v2.begin(), v2.end(), vDest.begin());

    cout << "v1 和 v2 的差集 dest" << endl;
    for_each(vDest.begin(),itEnd, vectorPrint);
    cout << endl;

    vDest.resize(max(v1.size(), v2.size()));
    itEnd = set_difference(v2.begin(), v2.end(), v1.begin(), v1.end(), vDest.begin());

    cout << "v2 和 v1 的差集 dest" << endl;
    for_each(vDest.begin(),itEnd, vectorPrint);
    cout << endl;
}

int main() {
    test01();
    return 0;
}